BOOL InitPlaneBlend(IDirect3DDevice8* pdevice) { //////////////////////// Local variables //////////////////////// BOOL res = TRUE ; VertexB2 locPlaneData[((MAX_PLANE_TESS_LEVEL_HORZ*2)+1) * ((MAX_PLANE_TESS_LEVEL_VERT*2)+1)] ; Face locFaceData[((MAX_PLANE_TESS_LEVEL_HORZ*2)*(MAX_PLANE_TESS_LEVEL_VERT*2))*4] ; DWORD i, j ; float fHorzPosShift, fVertPosShift ; float fHorzTextureCoordShift ; float fVertTextureCoordShift ; float tu, tv ; DWORD iIndex ; D3DVECTOR Position = { 0.0f } ; D3DVECTOR Normal = { 0.0f, 0.0f, -1.0f } ; DWORD dwNumIndices, dwNumVertices ; DWORD a,b,c, k ; DWORD dwCount1, dwCount2 ; float fWeightStartHorz, fWeightStartVert, fWeightShiftHorz, fWeightShiftVert ; //////////////////////////////////////////////////////////// LogMsg("\n In InitPlaneBlend \n") ; /* The following code sets up the plane data. This has been explained -- -- in detail on the web page. It's just plain linear math. Shouldn't be too much of a problem. Hope my code is correct. What I am doing here is linearly interpolate Position, texture co-ordinates, and blending weights based on the tesselation level and physical parameters of the plane. */ ZeroMemory(locPlaneData, sizeof(locPlaneData)) ; ZeroMemory(locFaceData, sizeof(locFaceData)) ; fHorzTextureCoordShift = 0.5f / ((((float)MAX_PLANE_TESS_LEVEL_HORZ)+0.0f)) ; fVertTextureCoordShift = 0.5f / ((((float)MAX_PLANE_TESS_LEVEL_VERT)+0.0f)) ; fHorzPosShift = (((FLOAT)PLANE_WIDTH) * 0.5f) / ((float)MAX_PLANE_TESS_LEVEL_HORZ) ; fVertPosShift = (((FLOAT)PLANE_HEIGHT) * 0.5f) / ((float)MAX_PLANE_TESS_LEVEL_VERT) ; fWeightShiftHorz = (0.5f) / ((float)MAX_PLANE_TESS_LEVEL_HORZ) ; fWeightShiftVert = (0.0f) ; tu = 0.0f ; tv = 0.0f ; iIndex = 0 ; Position.x = -((((FLOAT)PLANE_WIDTH) * 0.5f)) ; Position.y = ((((FLOAT)PLANE_HEIGHT) * 0.5f)) ; Position.z = 0.0f ; g_dwpbNumVertices = dwNumVertices = ((MAX_PLANE_TESS_LEVEL_HORZ*2)+1) * ((MAX_PLANE_TESS_LEVEL_VERT*2)+1) ; dwCount1 = ((MAX_PLANE_TESS_LEVEL_VERT*2)+1) ; dwCount2 = ((MAX_PLANE_TESS_LEVEL_HORZ*2)+1) ; for(i=0;i= 0.5f) { locPlaneData[iIndex].Weights[0] = fWeightStartHorz ; locPlaneData[iIndex].Weights[1] = 1.0f-fWeightStartHorz ; locPlaneData[iIndex].Indices[0] = (BYTE)(0) ; locPlaneData[iIndex].Indices[1] = (BYTE)(1) ; } else { locPlaneData[iIndex].Weights[1] = fWeightStartHorz ; locPlaneData[iIndex].Weights[0] = 1.0f-fWeightStartHorz ; locPlaneData[iIndex].Indices[1] = (BYTE)(0) ; locPlaneData[iIndex].Indices[0] = (BYTE)(1) ; } fWeightStartHorz -= fWeightShiftHorz ; Position.x += (fHorzPosShift) ; } Position.x = -((((FLOAT)PLANE_WIDTH) * 0.5f)) ; Position.y += -(fVertPosShift) ; } g_dwpbNumIndices = dwNumIndices = ((MAX_PLANE_TESS_LEVEL_HORZ*2)*(MAX_PLANE_TESS_LEVEL_VERT*2))*2 ; dwCount1 = (MAX_PLANE_TESS_LEVEL_VERT*2) ; dwCount2 = (MAX_PLANE_TESS_LEVEL_HORZ*2)*2 ; for(i=0;i